/**
 * author: XGP
 * date: 2018/07/25
 * des: 人员招聘-招聘规划
 *
 */
import {
  getPositionApi,
  getRankApi
} from './api'
/**
 * 候选，初选通过，面试列表
 */
export const CandidateSetting = [{
  field: 'intvName',
  title: '姓名',
  type: 'text'

},
{
  field: 'position',
  title: '岗位',

  type: 'text',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'POST',
  searchable: true
},
{
  field: 'reqName',
  title: '招聘需求',
  type: 'text',
  isParams: false,
  url: '/dropdownlists/selectReqList'
},
{
  field: 'sex',
  title: '性别',
  customText: (item) => {
    switch (item.sex) {
      case '1':
        return '男'
      case '2':
        return '女'
    }
  },
  type: 'text',

},
{
  field: 'age',
  title: '年龄',
  type: 'age'
},
{
  field: 'workLife',
  title: '工作年限',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'EXPERIENCEWORK'
},
{
  field: 'education',
  title: '学历',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'EDUCATION'
},
{
  field: 'graduationSchool',
  title: '毕业院校',
  type: 'text'
},
{
  field: 'lastCompany',
  title: '最近工作单位',
  type: 'text'
},
{
  field: 'mobile',
  title: '手机',
  type: 'number'
},
{
  field: 'email',
  title: '邮箱',
  type: 'email'
},
{
  field: 'recruitmentChannel',
  title: '招聘渠道',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'RECRUITMENTCHANNEL'
}
]
/**
 * 面试通过，offer审批，offer反馈列表
 */
export const passInterviesSetting = [{
  field: 'intvName',
  title: '姓名',
  type: 'text'
}, {
  field: 'remarks',
  title: '意见',
  type: 'textarea',
  onlyRow: true
},
{
  field: 'position',
  title: '岗位',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'POST',
},
{
  field: 'reqName',
  title: '招聘需求',
  type: 'text'
},
{
  field: 'sex',
  title: '性别',
  customText: (item) => {
    switch (item.sex) {
      case '1':
        return '男'
      case '2':
        return '女'
    }
  },
  type: 'radio'
},
{
  field: 'age',
  title: '年龄',
  type: 'age'
},
{
  field: 'workLife',
  title: '工作年限',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'EXPERIENCEWORK'
},
{
  field: 'education',
  title: '学历',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'EDUCATION'
},
{
  field: 'graduationSchool',
  title: '毕业院校',
  type: 'text'
},
{
  field: 'lastCompany',
  title: '最近工作单位',
  type: 'text'
},
{
  field: 'mobile',
  title: '手机',
  type: 'number'
},
{
  field: 'email',
  title: '邮箱',
  type: 'email'
},
{
  field: 'recruitmentChannel',
  title: '招聘渠道',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'RECRUITMENTCHANNEL'
}
]

/**
 * 新增候选人
 */
export const addSetting = [{
  field: 'reqId',
  title: '招聘需求',
  type: 'selectbyurl',
  url: '/dropdownlists/selectReqList',
  searchable: true
},
{
  field: 'intvName',
  title: '姓名',
  type: 'text',
  searchable: true
},
{
  field: 'mobile',
  title: '手机号码',
  type: 'number'
},
{
  field: 'email',
  title: '邮箱',
  type: 'email'
},
{
  field: 'graduationSchool',
  title: '毕业院校',
  type: 'text'
},
{
  field: 'education',
  title: '学历',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'EDUCATION'
},
{
  field: 'sex',
  title: '性别',
  type: 'radio',
  optional: [{
    name: '男',
    value: '1'
  },
  {
    name: '女',
    value: '2'
  }
  ]
},
{
  field: 'age',
  title: '年龄',
  type: 'age'
},

{
  field: 'recruitmentChannel',
  title: '招聘渠道',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'RECRUITMENTCHANNEL',
  searchable: true
},
{
  field: 'graduationDate',
  title: '毕业日期',
  type: 'date'
},
{
  field: 'workLife',
  title: '工作年限',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'EXPERIENCEWORK'
},
{
  field: 'lastCompany',
  title: '最近工作单位',
  type: 'text'
},
{
  field: 'status',
  title: '状态',
  type: 'text',
  disableEdit: true,
  hideEdit: true
},
{
  field: 'approvalFlag',
  title: '审批标志',
  type: 'radio',
  disableEdit: true,
  hideEdit: true,
  optional: [
    {
      name:'不通过',
      value:'0'
    },
    {
      name:'通过',
      value:'1'
    }
  ]

},
{
  field: 'remarks',
  title: '备注',
  type: 'text'
},
{
  field: 'docList',
  title: '简历',
  type: 'file',
  busiKey: 'intvId'
}
]


/**
 * 编辑候选人
 */
export const editSetting = [{
  field: 'reqId',
  title: '招聘需求',
  type: 'selectbyurl',
  url: '/dropdownlists/selectReqList'
},
{
  field: 'intvName',
  title: '姓名',
  type: 'text'
},

{
  field: 'mobile',
  title: '手机',
  type: 'number'
},
{
  field: 'email',
  title: '邮箱',
  type: 'email'
},
{
  field: 'graduationSchool',
  title: '毕业院校',
  type: 'text'
},
{
  field: 'education',
  title: '学历',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'EDUCATION'
},

{
  field: 'sex',
  title: '性别',
  type: 'radio',
  optional: [{
    name: '男',
    value: '1'
  },
  {
    name: '女',
    value: '2'
  }
  ]
},
{
  field: 'age',
  title: '年龄',
  type: 'age'
},
{
  field: 'recruitmentChannel',
  title: '招聘渠道',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'RECRUITMENTCHANNEL'
},

{
  field: 'graduationDate',
  title: '毕业日期',
  type: 'date'
},
{
  field: 'workLife',
  title: '工作年限',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'EXPERIENCEWORK'
},
{
  field: 'lastCompany',
  title: '最近工作单位',
  type: 'text'
},
{
  field: 'status',
  title: '状态',
  type: 'text',
  disableEdit: true,
  hideEdit: true
},
{
  field: 'remarks',
  title: '备注',
  type: 'text'
},
{
  field: 'docList',
  title: '简历',
  type: 'file',
  busiKey: 'intvId'
}
]




/**
 * 面试编辑，
 */
export const interviesEditSetting = [{
  field: 'appointmentInterviewer',
  title: '面试官',
  type: 'text'
}, {
  field: 'appointmentInterviewDate',
  title: '面试日期',
  type: 'date'
},
{
  field: 'appointmentInterviewTime',
  title: '面试时间',
  type: 'time'
},
{
  field: 'appointmentInterviewAddr',
  title: '面试地点',
  type: 'text'
}
]

/**
 * 淘汰流失原因，
 */
export const eliminationSetting = [{
  field: 'eliminationReason',
  title: '淘汰流失原因',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'ELIMINATEREASON'
}, {
  field: 'eliminationType',
  title: '淘汰类型',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'ELIMINATETYPE'
},
{
  field: 'remarks',
  title: '备注',
  type: 'text'
}
]
/**
 * offer审批发送申请
 */
export const offerSendSetting = [{
  field: 'intvName',
  title: '姓名',
  type: 'text',
  disableEdit: true
},
{
  field: 'reqId',
  title: '招聘需求',
  type: 'selectbyurl',
  url: '/dropdownlists/selectReqList',
  disableEdit: true
},
{
  field: 'mobile',
  title: '手机',
  type: 'number',
  disableEdit: true
},
{
  field: 'email',
  title: '邮箱',
  type: 'text',
  disableEdit: true
},
{
  field: 'recruitmentChannel',
  title: '招聘渠道',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'RECRUITMENTCHANNEL',
  disableEdit: true
},
{
  field: 'orgId',
  title: '部门',
  type: 'org',
  init: (form, item) => {
    const params = {
      orgId: form.orgId
    }
    const options = []
    getPositionApi(params).then(response => {
      if (response.success) {
        let data = []
        if (response.data) {
          data = response.data
        }
        data.forEach(v => {
          const a = {
            name: v.postName,
            value: v.postId
          }
          options.push(a)
        })
        offerSendSetting.forEach(v => {
          if (v.field === 'position') {
            v.options = options
          }
        })
      }
    })
  },
  itemChange: (form, b, c) => {
    const params = {
      orgId: form.orgId
    }
    const options = []
    getPositionApi(params).then(response => {
      if (response.success) {
        let data = []
        if (response.data) {
          data = response.data
        }
        data.forEach(v => {
          const a = {
            name: v.postName,
            value: v.postId
          }
          options.push(a)
        })
        form.position = ''
        form.postLevel = ''
        offerSendSetting.forEach(v => {
          if (v.field === 'position') {
            v.options = []
            v.options = options
          }
        })
      }
    })
  }
},
{
  field: 'position',
  title: '岗位',
  info: '部门、岗位、职级为三级联动：部门 > 岗位 > 职级',
  type: 'selected',
  options: [],
  init: (form, item) => {
    if (form.orgId && form.position) {
      const params = {
        orgId: form.orgId,
        postId: form.position
      }
      const options = []
      getRankApi(params).then(response => {
        if (response.success) {
          if (response.data) {
            response.data.forEach(v => {
              const a = {
                name: v.name,
                value: v.id
              }
              options.push(a)
            })
            offerSendSetting.forEach(v => {
              if (v.field === 'postLevel') {
                v.options = options
              }
            })
          }
        }
      })
    }
  },
  itemChange: (form, item) => {
    if (form.orgId && form.position) {
      const params = {
        orgId: form.orgId,
        postId: form.position
      }
      const options = []
      getRankApi(params).then(response => {
        if (response.success) {
          if (response.data) {
            response.data.forEach(v => {
              const a = {
                name: v.name,
                value: v.id
              }
              options.push(a)
            })
            form.postLevel = ''
            offerSendSetting.forEach(v => {
              if (v.field === 'postLevel') {
                v.options = options
              }
            })
          }
        }
      })
    }
  }
},
{
  field: 'postLevel',
  title: '职级',
  info: '部门、岗位、职级为三级联动：部门 > 岗位 > 职级',
  type: 'selected',
  options: []
},
{
  field: 'workNature',
  title: '工作性质',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'NATUREWORK'
},
{
  field: 'entryDate',
  title: '预计入职日期',
  type: 'date'
},
{
  field: 'remarks1',
  title: '意见',
  type: 'textarea',
  onlyRow: true
}
]
/**
 * 发送offer/放弃
 */
export const sendOfferSetting = [{
  field: 'intvName',
  title: '姓名',
  type: 'text',
  disableEdit: true
},
{
  field: 'reqId',
  title: '招聘需求',
  disableEdit: true,
  type: 'selectbyurl',
  url: '/dropdownlists/selectReqList'
},
{
  field: 'mobile',
  title: '手机',
  type: 'number',
  disableEdit: true
},
{
  field: 'email',
  title: '邮箱',
  type: 'email',
  disableEdit: true
},
{
  field: 'recruitmentChannel',
  title: '招聘渠道',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'RECRUITMENTCHANNEL',
  disableEdit: true
},
{
  field: 'eliminationReason',
  title: '淘汰流失原因',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'ELIMINATEREASON'
}, {
  field: 'eliminationType',
  title: '淘汰类型',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'ELIMINATETYPE'
},
{
  field: 'remarks',
  title: '备注',
  type: 'text'
}
]


/**
 * 移动到面试通过
 */
export const removeInterviewPassSetting = [{
  field: 'appointmentInterviewer',
  title: '面试官',
  type: 'text',
  disableEdit: true
}, {
  field: 'appointmentInterviewDate',
  title: '面试日期',
  type: 'date',
  disableEdit: true
}, {
  field: 'appointmentInterviewTime',
  title: '面试时间',
  type: 'time',
  disableEdit: true
},
{
  field: 'appointmentInterviewAddr',
  title: '面试地点',
  type: 'text',
  disableEdit: true
},
{
  field: 'docList',
  title: '简历附件',
  type: 'file',
  busiKey: 'intvId',
  isHiden: true,
  disableEdit: true
},
{
  field: 'remarks',
  title: '面试评语',
  type: 'textarea'
},
{
  field: 'suggest',
  title: '面试意见',
  info: '等待下次复试：先将面试人员移动到面试通过，等待重新安排复试',
  type: 'radio',
  optional: [{
    name: '通过',
    value: '1'
  },
  {
    name: '马上复试',
    value: '2'
  },
  {
    name: '等待下次复试',
    value: '3'
  }
  ]
},
{
  field: 'appointmentInterviewer2',
  title: '复试面试官',
  type: 'text',
  showEditSituation: (form) => {
    if (form.suggest === '1') {
      return false
    }
    if (form.suggest === '2') {
      return true
    }
    if (form.suggest === '3') {
      return true
    }
    return false
  }
}

]

/**
 * 发送offer/放弃
 */
export const giveUpOfferSetting = [{
  field: 'intvName',
  title: '姓名',
  type: 'text',
  disableEdit: true
},
{
  field: 'reqId',
  title: '招聘需求',
  disableEdit: true,
  type: 'selectbyurl',
  url: '/dropdownlists/selectReqList'
},
{
  field: 'mobile',
  title: '手机',
  type: 'number',
  disableEdit: true
},
{
  field: 'email',
  title: '邮箱',
  type: 'email',
  disableEdit: true
},
{
  field: 'recruitmentChannel',
  title: '招聘渠道',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'RECRUITMENTCHANNEL',
  disableEdit: true
},
{
  field: 'remarks',
  title: '备注',
  type: 'text'
}
]


/**
 * 审批
 */
export const approveSetting = [{
  field: 'intvName',
  title: '姓名',
  type: 'text',
  disableEdit: true
},
{
  field: 'reqId',
  title: '招聘需求',
  type: 'selectbyurl',
  url: '/dropdownlists/selectReqList',
  disableEdit: true
},
{
  field: 'mobile',
  title: '手机',
  type: 'number',
  disableEdit: true
},
{
  field: 'email',
  title: '邮箱',
  type: 'email',
  disableEdit: true
},
{
  field: 'recruitmentChannel',
  title: '招聘渠道',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'RECRUITMENTCHANNEL',
  disableEdit: true
},
{
  field: 'orgId',
  title: '部门',
  type: 'org',
  disableEdit: true
},
{
  field: 'position',
  title: '岗位',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'POST',
  disableEdit: true
},
{
  field: 'postLevel',
  title: '职级',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'RANK',
  disableEdit: true
},
{
  field: 'workNature',
  title: '工作性质',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'NATUREWORK',
  disableEdit: true
},
{
  field: 'entryDate',
  title: '预计入职日期',
  type: 'date',
  disableEdit: true
},
{
  field: 'docList',
  title: '简历',
  type: 'file',
  busiKey: 'intvId',
  disableEdit: true
},
{
  field: 'approvalOpinion',
  title: '审批意见',
  type: 'textarea',
  onlyRow: true,
  isHiden: true
}
]




/**
 * feedbackNoSetting,feedbackSetting
 * 反馈通过
 */
export const feedbackYesSetting = [{
  field: 'intvName',
  title: '姓名',
  type: 'text',
  disableEdit: true
},

{
  field: 'mobile',
  title: '手机',
  type: 'number',
  disableEdit: true
},
{
  field: 'email',
  title: '邮箱',
  type: 'email',
  disableEdit: true
},

{
  field: 'approvalFlag',
  title: '审批标志',
  type: 'radio',
  disableEdit: true,
  optional: [
    {
      name:'不通过',
      value:'0'
    },
    {
      name:'通过',
      value:'1'
    }
  ]

},
{
  field: 'recruitmentChannel',
  title: '招聘渠道',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'RECRUITMENTCHANNEL',
  disableEdit: true
},
{
  field: 'reqId',
  title: '招聘需求',
  type: 'selectbyurl',
  url: '/dropdownlists/selectReqList',
  disableEdit: true
},
{
  field: 'orgId',
  title: '入职部门',
  type: 'org',
  init: (form, item) => {
    const params = {
      orgId: form.orgId
    }
    const options = []
    getPositionApi(params).then(response => {
      if (response.success) {
        let data = []
        if (response.data) {
          data = response.data
        }
        data.forEach(v => {
          const a = {
            name: v.postName,
            value: v.postId
          }
          options.push(a)
        })
        feedbackYesSetting.forEach(v => {
          if (v.field === 'position') {
            v.options = options
          }
        })
      }
    })
  },
  itemChange: (form, b, c) => {
    const params = {
      orgId: form.orgId
    }

    const options = []
    getPositionApi(params).then(response => {
      if (response.success) {
        let data = []
        if (response.data) {
          data = response.data
        }
        data.forEach(v => {
          const a = {
            name: v.postName,
            value: v.postId
          }
          options.push(a)
        })
        feedbackYesSetting.forEach(v => {
          if (v.field === 'position') {
            v.options = []
            form.position = ''
            v.options = options
          }
          if (v.field === 'postLevel') {
            form.postLevel = ''
          }
        })
      }
    })
  }
},
{
  field: 'position',
  title: '入职岗位',
  info: '部门、岗位、职级为三级联动：部门 > 岗位 > 职级',
  type: 'selected',
  options: [],
  init: (form, item) => {
    if (form.orgId && form.position) {
      const params = {
        orgId: form.orgId,
        postId: form.position
      }
      const options = []
      getRankApi(params).then(response => {
        if (response.success) {
          if (response.data) {
            response.data.forEach(v => {
              const a = {
                name: v.name,
                value: v.id
              }
              options.push(a)
            })
            feedbackYesSetting.forEach(v => {
              if (v.field === 'postLevel') {
                v.options = options
              }
            })
          }
        }
      })
    }
  },
  itemChange: (form, item) => {
    if (form.orgId && form.position) {
      const params = {
        orgId: form.orgId,
        postId: form.position
      }
      const options = []
      getRankApi(params).then(response => {
        if (response.success) {
          if (response.data) {
            response.data.forEach(v => {
              const a = {
                name: v.name,
                value: v.id
              }
              options.push(a)
            })
            feedbackYesSetting.forEach(v => {
              if (v.field === 'postLevel') {
                form.postLevel = ''
                v.options = options
              }
            })
          }
        }
      })
    }
  }
},
{
  field: 'postLevel',
  title: '担任职级',
  info: '部门、岗位、职级为三级联动：部门 > 岗位 > 职级',
  type: 'selected',
  options: []
},
{
  field: 'workNature',
  title: '工作性质',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'NATUREWORK'
},
{
  field: 'entryDate',
  title: '预计入职日期',
  type: 'date'
}
]
/**
 * 反馈不通过
 */
export const feedbackNoSetting = [{
  field: 'intvName',
  title: '姓名',
  type: 'text',
  disableEdit: true
},
{
  field: 'reqId',
  title: '招聘需求',
  disableEdit: true,
  type: 'selectbyurl',
  url: '/dropdownlists/selectReqList'
},
{
  field: 'mobile',
  title: '手机',
  type: 'number',
  disableEdit: true
},
{
  field: 'email',
  title: '邮箱',
  type: 'email',
  disableEdit: true
},
{
  field: 'remarks',
  title: '意见',
  type: 'textarea',
  onlyRow: true,
  disableEdit: true
},
{
  field: 'approvalFlag',
  title: '审批标志',
  type: 'radio',
  disableEdit: true,
  optional: [
    {
      name:'不通过',
      value:'0'
    },
    {
      name:'通过',
      value:'1'
    }
  ]

},
{
  field: 'recruitmentChannel',
  title: '招聘渠道',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'RECRUITMENTCHANNEL',
  disableEdit: true
},
{
  field: 'eliminationReason',
  title: '淘汰流失原因',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'ELIMINATEREASON'
}, {
  field: 'eliminationType',
  title: '淘汰类型',
  type: 'selected',
  isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
  paramsId: 'ELIMINATETYPE'
}
]

export const searchSetting = [
  {
    field: 'reqId',
    title: '招聘需求',
    type: 'selectbyurl',
    url: '/dropdownlists/selectReqList',
    searchable: true
  },
  {
    field: 'intvName',
    title: '面试者姓名',
    type: 'text',
    searchable: true
  },
  {
    field: 'graduationSchool',
    title: '毕业院校',
    type: 'text',
    searchable: true
  },
  {
    field: 'education',
    title: '最高学历',
    type: 'selected',
    isParams: true, // 默认为false，当isParams 为true 时，下拉数据为参数类型，
    paramsId: 'EDUCATION',
    searchable: true
  }
]
